package com.waimai1.waimai.service.impl;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.waimai1.waimai.common.BaseContext;
import com.waimai1.waimai.dao.CouponPersonDao;
import com.waimai1.waimai.dto.CouponPersonWhiteDto;
import com.waimai1.waimai.entity.ChoujiangWhite;
import com.waimai1.waimai.entity.CouponPerson;
import com.waimai1.waimai.service.CouponPersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.sql.Array;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * (CouponPerson)表服务实现类
 *
 * @author makejava
 * @since 2023-11-04 17:32:39
 */
@Service("couponPersonService")
public class CouponPersonServiceImpl extends ServiceImpl<CouponPersonDao, CouponPerson> implements CouponPersonService {
@Autowired
    private RedisTemplate redisTemplate;
    public  void saveExcel(List<CouponPersonWhiteDto> whiteList) {
        Set phones=new HashSet();
        for(CouponPersonWhiteDto white:whiteList){
            phones.add(white.getPhone());
        }
        redisTemplate.opsForSet().add(BaseContext.getAcid()+":couponPersonWhite"+BaseContext.getWexinNo(),phones.toArray());
    }
    public void clearExcelRedis(){
        redisTemplate.delete("couponPersonWhite"+BaseContext.getWexinNo());
    }
    public  long saveWhite(String[] phones) {
         return redisTemplate.opsForSet().add(BaseContext.getAcid()+":couponPersonWhite"+BaseContext.getWexinNo(), phones);
    }
}

